import { routes, RouteConfig } from './routes';

// 根据路径获取路由配置
export const getRouteByPath = (path: string): RouteConfig | undefined => {
  return routes.find(route => route.path === path);
};

// 获取所有路由路径
export const getAllPaths = (): string[] => {
  return routes.map(route => route.path);
};

// 检查路径是否存在
export const isPathExists = (path: string): boolean => {
  return routes.some(route => route.path === path);
};

// 获取路由标题
export const getRouteTitle = (path: string): string => {
  const route = getRouteByPath(path);
  return route?.title || '未知页面';
};

// 获取面包屑导航
export const getBreadcrumbs = (path: string): Array<{ title: string; path: string }> => {
  const breadcrumbs = [{ title: '首页', path: '/dashboard' }];
  
  if (path === '/dashboard') {
    return breadcrumbs;
  }
  
  const route = getRouteByPath(path);
  if (route) {
    breadcrumbs.push({ title: route.title, path: route.path });
  }
  
  return breadcrumbs;
}; 